home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: miker3@ix.netcom.com (Mike Rubenstein)
- Newsgroups: comp.lang.c++
- Subject: Re: Q:order of evaluation
- Date: Sat, 27 Jan 1996 03:00:27 GMT
- Organization: Netcom
- Message-ID: <31098f8f.11689344@nntp.ix.netcom.com>
- References: <4dfhlu$a33$1@mhafn.production.compuserve.com> <hamilton-1801962045570001@dialup-147.austin.io.com> <4dpcfo$293@clarknet.clark.net> <hamilton-2401960104020001@dialup-86.austin.io.com> <3108c867.40236096@nntp.ix.netcom.com> <4eb6kq$ksf@gazette.tandem.com>
- NNTP-Posting-Host: ix-dc17-13.ix.netcom.com
- X-NETCOM-Date: Fri Jan 26 7:00:40 PM PST 1996
- X-Newsreader: Forte Agent .99c/16.141
-
- yun_yeogirl <yyg> wrote:
-
- > Michael M Rubenstein wrote :
- >
- > [Example:
- > i = v[i++]; // the behavior is undefined
- > i = 7,i++,i++; // `i' becomes 9
- >
- > i = ++i + 1; // the behavior is undefined
- > i = i + 1; // the value of 'i' is incremented
- >
- > The first and third statement seem clear to me. I don't see why they are
- > undefined. I guess you made a typo here. Maybe you meant :
- >
- > i + v[i++] and i + (++i + 1).
- >
- > If I am wrong, please enlighten me.
-
- No typo. I copied that directly from the draft.
-
- Let's look at the first. The only sequence points are the one at the
- end and the presumed one at the end of the previous expression. There
- is no sequence point between the incrementing for i++ and the
- assignment to i for =. The problem is that the draft (following the C
- standard) allows side effects to occur at any time between sequence
- points. Possible valuations include both
-
- 1. evaluate v[i].
- 2. increment i.
- 3. store the result of 1 in i.
-
- and
-
- 1. evaluate v[i].
- 2. store the result of 1 in i.
- 3. increment i.
-
- There are other possibilities (ignoring the fact that anything is
- possible since the behavior is undefined).
-
-
- Michael M Rubenstein
-